package com.amado.easyui2.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.amado.easyui2.dao.ExportDao;
import com.amado.easyui2.domain.CoachStaffEntity;

public class ExportDaoImpl implements ExportDao {

	@Override
	public List<CoachStaffEntity> listAll() {
		Connection conn = JDBC.getConn();
		String sql = "select * from t_coach_staff";
		PreparedStatement ps = null;
		ResultSet rs = null;
		List<CoachStaffEntity> coach = new ArrayList();
		try {
			ps = conn.prepareStatement(sql);
			rs = ps.executeQuery();
			while (rs.next()) {
				int i = 1;
				Long id = rs.getLong(i++);
				String drivingSchoolName = rs.getString("driving_school_name");
				
				String coachName = rs.getString("coach_name");
				String coachNumber = rs.getString("coach_number");
				String coachIdCard = rs.getString("coach_id_card");
				String coachSex = rs.getString("coach_sex");
				String coachDateBirth = rs.getString("coach_date_birth");
				String nation = rs.getString("nation");
				String quasiDrivingType = rs.getString("quasi_driving_type");
				String mustTeachModels = rs.getString("must_teach_models");
				String placeOfDomicile = rs.getString("place_of_domicile");
				String phone = rs.getString("phone");
				String referenceStatus = rs.getString("reference_status");
				String returnMessage = rs.getString("return_message");
				String popedom = rs.getString("popedom");
				String province = rs.getString("province");
				String city = rs.getString("city");
				String contactAddress = rs.getString("contact_address");
				String mustTeachClasses = rs.getString("must_teach_classes");
				String learnHistory = rs.getString("learn_history");
				String socialSecurityNumber = rs.getString("social_security_number");
				Date drivingLicenceStatsTime = rs.getDate("driving_licence_stats_time");
				Date pactEndTime = rs.getDate("pact_end_time");
				Date pactStatsTime = rs.getDate("pact_stats_time");
				String workingState = rs.getString("working_state");
				Date certificateTime = rs.getDate("certificate_time");
				Date validTime = rs.getDate("valid_time");
				String deleteLogo = rs.getString("delete_logo");
				String learnCardNumber = rs.getString("learn_card_number");
				Date createTime=rs.getTimestamp("create_time");
				Date updateTime=rs.getTimestamp("update_time");
				String createName=rs.getString("create_name");
				String updateName=rs.getString("update_name");
				coach.add(new CoachStaffEntity(id, drivingSchoolName, coachName, coachNumber, coachIdCard, coachSex,
						coachDateBirth, nation, quasiDrivingType, mustTeachModels, placeOfDomicile, phone,
						referenceStatus, returnMessage, popedom, province, city, contactAddress, mustTeachClasses,
						learnHistory, socialSecurityNumber, drivingLicenceStatsTime, pactStatsTime, pactEndTime,
						workingState, certificateTime, validTime,deleteLogo, learnCardNumber,createTime,updateTime,createName,updateName));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return coach;
	}

}
